<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

use Think\Model;

class DepositContractList
{
    public $login = false; //是否需要登录才能访问该接口
    public $title = "008保证金列表ok";
    public $group = '保证金';
    public $desc = "";

    public $input = [
    ];

    public $output = [
        'list' => [
            [
                'id' => 'label=id;',
                'house_id' => 'label=房间id;',
                'building_id' => 'label=楼栋id;',
                'building_name' => 'label=楼栋号;',
                'house_name' => 'label=房间号;',
                'real_name' => 'label=真实姓名;',
                'mobile' => 'label=手机号;',
                'is_deposit' => 'label=是否缴纳保证金： 1是 2否 ;',
            ]
        ]
    ];

    public function run($param, $uid)
    {
        $model = new Model();
        $sql = "SELECT a.id, a.house_id, a.building_id, a.is_deposit, c.`name` AS building_name,  d.`name` AS house_name,
a.start_time, a.end_time, a.state, e.mobile, e.real_name
FROM `k_house_contract` as a
LEFT JOIN k_building AS c ON c.id=a.building_id
LEFT JOIN k_house AS d ON d.id=a.house_id
LEFT JOIN k_user AS e ON e.uid=a.uid
WHERE  a.uid= {$uid};";
        $list = $model->query($sql);
        return [
            'list' => $list,
        ];
    }
}
